import java.sql.Connection;
import java.sql.DriverManager;

public class demo1 {
    public static void main(String[] args) throws Exception {
        // 1. 加载数据库驱动
        Class.forName("com.mysql.cj.jdbc.Driver");

        //2.获取连接
        String url ="jdbc:mysql://127.0.0.1:3306/test";
        String username ="root";
        String password ="wjl2005516";
        Connection conn = DriverManager.getConnection(url,username,password);

        if(conn != null)
        {
            System.out.println("连接成功");
            //执行语句

        }
        else {
            System.out.println("连接失败");
        }
    }
}
